<template>
  <div class="home_box">
    <div class="home_left_box">
      <div class="isCollapse_box">
        <p @click="isCollapse = !isCollapse">
          <i class="el-icon-s-fold" v-show="isCollapse"></i>
          <i class="el-icon-s-unfold" v-show="!isCollapse"></i>
        </p>
      </div>
      <el-menu
        :default-active="activePath"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
        :unique-opened="true"
        :router="true"
        text-color="#fff"
        active-text-color="#ffd04b"
        background-color="transparent"
      >
        <el-menu-item index="/home">
          <i class="el-icon-document" style="color: #fff"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <el-submenu index="/">
          <template slot="title">
            <i class="el-icon-location" style="color: #fff"></i>
            <span slot="title">element-ui组件</span>
          </template>
          <el-submenu index="/celltable">
            <span slot="title">el-table</span>
            <el-menu-item index="/celltable">递归合并单元格</el-menu-item>
          </el-submenu>
          <el-submenu index="1-2">
            <span slot="title">选项2</span>
            <el-menu-item index="1-2-1">选项2-1</el-menu-item>
          </el-submenu>
          <el-submenu index="1-3">
            <span slot="title">选项3</span>
            <el-menu-item index="1-3-1">选项3-1</el-menu-item>
          </el-submenu>
          <el-submenu index="1-4">
            <span slot="title">选项4</span>
            <el-menu-item index="1-4-1">选项1</el-menu-item>
          </el-submenu>
        </el-submenu>
        <el-menu-item index="/editor">
          <i class="el-icon-menu" style="color: #fff"></i>
          <span slot="title">富文本</span>
        </el-menu-item>
        <el-menu-item index="/echarts">
          <i class="el-icon-menu" style="color: #fff"></i>
          <span slot="title">echarts组件</span>
        </el-menu-item>
        <el-menu-item index="/svg">
          <i class="el-icon-setting" style="color: #fff"></i>
          <span slot="title">svg组件</span>
        </el-menu-item>
        <el-menu-item index="/UI">
          <i class="el-icon-setting" style="color: #fff"></i>
          <span slot="title">UI模块组件</span>
        </el-menu-item>
        <el-menu-item index="/baidumap">
          <i class="el-icon-setting" style="color: #fff"></i>
          <span slot="title">百度地图</span>
        </el-menu-item>
        <el-menu-item index="/styleindex">
          <i class="el-icon-setting" style="color: #fff"></i>
          <span slot="title">样式</span>
        </el-menu-item>
        <el-menu-item index="/video">
          <i class="el-icon-setting" style="color: #fff"></i>
          <span slot="title">视频类</span>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="home_right_box">
      <router-view />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      activePath: "/",
    };
  },
  created() {
    // console.log(this.$route, "路由信息");
    this.activePath = this.$route.meta.active;
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style lang="sss" scoped>
.home_box {
  display: flex;
  min-height: calc(100vh - 130px);
}
.home_left_box {
  position: relative;
  background: #005aa7; /* fallback for old browsers */
  background: -webkit-linear-gradient(
    to right,
    #005aa7,
    #0b8793
  ); /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(
    to right,
    #005aa7,
    #0b8793
  ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.home_right_box {
  flex: 1;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
}
.isCollapse_box {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 30px;
  text-align: center;
  color: azure;
  border-bottom: 1px solid #1394a0;
}
.home_left_box >>> .el-submenu__title i {
  color: #fff;
  font-size: 16px !important;
}
.home_left_box >>> .el-menu {
  border: none;
}
.home_left_box >>> .el-submenu__title:hover {
  background-color: #1394a0 !important;
}
.home_left_box >>> .el-menu-item:hover {
  background-color: #1394a0 !important;
}
.home_left_box >>> .el-menu-item.is-active {
  background-color: #1394a0 !important;
  color: #ffd04b !important;
}
.menu_link {
  display: inline-block;
  width: 100%;
  height: 100%;
}
.menu_link span {
  color: #fff;
  font-size: 16px;
}
</style>